

package com.hazelcast.jet.test;

import com.hazelcast.config.helpers.DeclarativeConfigFileHelper;

import java.io.File;
import java.net.URL;

public class JetDeclarativeConfigFileHelper extends DeclarativeConfigFileHelper {

    public URL givenYamlJetConfigFileOnClasspath(String filename, String property, String value) throws Exception {
        String yaml = yamlJetConfigWithProperty(property, value);
        return givenConfigFileOnClasspath(filename, yaml);
    }

    public URL givenYmlJetConfigFileOnClasspath(String filename, String property, String value) throws Exception {
        String yaml = yamlJetConfigWithProperty(property, value);
        return givenConfigFileOnClasspath(filename, yaml);
    }

    public File givenYamlJetConfigFileOnWorkdir(String filename, String property, String value) throws Exception {
        String yaml = yamlJetConfigWithProperty(property, value);
        return givenConfigFileInWorkDir(filename, yaml);
    }

    public File givenYmlJetConfigFileOnWorkdir(String filename, String property, String value) throws Exception {
        String yaml = yamlJetConfigWithProperty(property, value);
        return givenConfigFileInWorkDir(filename, yaml);
    }

    public File givenXmlJetConfigFileOnWorkdir(String filename, String property, String value) throws Exception {
        String xml = xmlJetConfigWithProperty(property, value);
        return givenConfigFileInWorkDir(filename, xml);
    }

    private String yamlJetConfigWithProperty(String property, String value) {
        return "hazelcast-jet:\n" + "  properties:\n" + "    " + property + ": " + value + "\n";
    }

    private String xmlJetConfigWithProperty(String property, String value) {
        return "<hazelcast-jet xmlns=\"http://www.hazelcast.com/schema/jet-config\">\n<properties>\n" + "<property name=\"" + property + "\">" + value + "</property>\n</properties>\n" + "</hazelcast-jet>";
    }
}
